<?php
$start_time = mktime(20,0,0,5,11,2018);
$end_time   = mktime(20,0,0,5,18,2018);
$new_time   = time() + 1;
// 比赛未开始
if($start_time > $new_time){
	$diff_time  = $start_time - $new_time;
	$slogan = '<strong>AFCTF</strong> is coming!';
}
// 比赛结束
elseif ($new_time > $end_time) {
	$diff_time  = 0;
	$slogan = '<strong>AFCTF</strong> END! SEE U NEXT TIME!';
}
// 比赛已开始
elseif($new_time > $start_time){
	$diff_time  = $end_time - $new_time;
	$slogan = 'ENJOY YOUR <strong>HACK</strong> TIME';
}
$days = intval($diff_time/86400);
//计算小时数
$remain = $diff_time%86400;
$hours = intval($remain/3600);
//计算分钟数
$remain = $remain%3600;
$mins = intval($remain/60);
//计算秒数
$secs = $remain%60;
if($days < 10){
	$day1 = 0;
	$day2 = $days;
}
else{
	$day1  = substr($days,0,1);
	$day2  = substr($days,1,1);
}
if($hours < 10){
	$hour1 = 0;
	$hour2 = $hours;
}
else{
	$hour1 = substr($hours,0,1);
	$hour2 = substr($hours,1,1);
}
if($mins < 10){
	$min1 = 0;
	$min2 = $days;
}
else{
	$min1  = substr($mins,0,1);
$min2  = substr($mins,1,1);
}
if($secs < 10){
	$sec1 = 0;
	$sec2 = $secs;
}
else{
	$sec1  = substr($secs,0,1);
	$sec2  = substr($secs,1,1);
}
if($new_time > $end_time){
	$day1 = 0;
	$day2 = 0;
	$hour1 = 0;
	$hour2 = 0;
	$min1 = 0;
	$min2 = 0;
	$sec1 = 0;
	$sec2 = 0;
}
echo <<<countdown
	<div class="container">
		<div class="c_wrap">  
		  <h1 id="h_countdown">$slogan</h1>

		  <div class="countdown">
		  <div class="bloc-time days">
		      <span class="count-title">Days</span>

		      <div class="figure days days-1">
		        <span class="top">$day1</span>
		        <span class="top-back">
		          <span>$day1</span>
		        </span>
		        <span class="bottom">$day1</span>
		        <span class="bottom-back">
		          <span>$day1</span>
		        </span>
		      </div>

		      <div class="figure days days-2">
		        <span class="top">$day2</span>
		        <span class="top-back">
		          <span>$day2</span>
		        </span>
		        <span class="bottom">$day2</span>
		        <span class="bottom-back">
		          <span>$day2</span>
		        </span>
		      </div>
		    </div>

		    <div class="bloc-time hours">
		      <span class="count-title">Hours</span>

		      <div class="figure hours hours-1">
		        <span class="top">$hour1</span>
		        <span class="top-back">
		          <span>$hour1</span>
		        </span>
		        <span class="bottom">$hour1</span>
		        <span class="bottom-back">
		          <span>$hour1</span>
		        </span>
		      </div>

		      <div class="figure hours hours-2">
		        <span class="top">$hour2</span>
		        <span class="top-back">
		          <span>$hour2</span>
		        </span>
		        <span class="bottom">$hour2</span>
		        <span class="bottom-back">
		          <span>$hour2</span>
		        </span>
		      </div>
		    </div>

		    <div class="bloc-time min">
		      <span class="count-title">Minutes</span>

		      <div class="figure min min-1">
		        <span class="top">$min1</span>
		        <span class="top-back">
		          <span>$min1</span>
		        </span>
		        <span class="bottom">$min1</span>
		        <span class="bottom-back">
		          <span>$min1</span>
		        </span>        
		      </div>

		      <div class="figure min min-2">
		       <span class="top">$min2</span>
		        <span class="top-back">
		          <span>$min2</span>
		        </span>
		        <span class="bottom">$min2</span>
		        <span class="bottom-back">
		          <span>$min2</span>
		        </span>
		      </div>
		    </div>

		    <div class="bloc-time sec">
		      <span class="count-title">Seconds</span>

		        <div class="figure sec sec-1">
		        <span class="top">$sec1</span>
		        <span class="top-back">
		          <span>$sec1</span>
		        </span>
		        <span class="bottom">$sec1</span>
		        <span class="bottom-back">
		          <span>$sec1</span>
		        </span>          
		      </div>

		      <div class="figure sec sec-2">
		        <span class="top">$sec2</span>
		        <span class="top-back">
		          <span>$sec2</span>
		        </span>
		        <span class="bottom">$sec2</span>
		        <span class="bottom-back">
		          <span>$sec2</span>
		        </span>
		      </div>
		    </div>
		  </div>
		</div>
	</div>
	<script src='js/TweenMax.min.js'></script>
	<script src="js/index.js"></script>
countdown;
?>